package lianxi;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class Pratice {
	public static void main(String[] args) throws ClassNotFoundException, SQLException, IOException {
		Map<String, String> datas = load("jdbc.properties");
		System.out.println(datas.get("username"));
		System.out.println(datas.get("password"));
		System.out.println(datas.get("url"));
		System.out.println(datas.get("driver"));

	}

	public static Map<String, String> load(String path) throws IOException {
		BufferedReader br = null;
		try {
			if (br == null) {
				br = new BufferedReader(new FileReader(path));
			}

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String tmp = null;
		Map<String, String> datas = new HashMap<String, String>();
		while ((tmp = br.readLine()) != null) {

			String[] arr = tmp.split("=");
			datas.put(arr[0], arr[1]);
		}
		return datas;
	}
}
